import Vue from 'vue'
import Router from 'vue-router'
// in development env not use Lazy Loading,because Lazy Loading too many pages will cause webpack hot update too slow.so only in production use Lazy Loading
/* layout */
import Layout from '../views/layout/Layout'

const _import = require('./_import_' + process.env.NODE_ENV)
Vue.use(Router)
export const constantRouterMap = [
  {path: '/login', component: _import('login/index'), hidden: true},
  {path: '/404', component: _import('404'), hidden: true},
  {
    path: '',
    component: Layout,
    redirect: '/dashboard',
    name: '首页',
    hidden: true,
    children: [{
      path: 'dashboard', component: _import('dashboard/index'),
      meta: {title: '西餐厅', icon: 'home'},
    }]
  }
]
export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})
export const asyncRouterMap = [
  {
    path: '/desk',
    component: Layout,
    redirect: '/desk/',
    name: 'desk',
    meta: {title: '桌位', icon: 'table'},
    children: [
      {
        path: '', name: '桌位', component: _import('desk/desk'), meta: {title: '桌位', icon: 'table'}, menu: 'desk'
      },
    ]
  },
  {
    path: '/pos/:id',
    component: Layout,
    redirect: '/pos/',
    name: 'pos',
    meta: {title: 'POS', icon: 'dishes'},
    children: [
      {
        path: '', name: 'POS', component: _import('pos/pos'), meta: {title: 'POS', icon: 'food'}, menu: 'dishes'
      },
    ],
    hidden: true
  },
  {
    path: '/order',
    component: Layout,
    redirect: '/order/',
    name: 'order',
    meta: {title: '账单', icon: 'order'},
    children: [
      {
        path: '', name: '账单', component: _import('order/order'), meta: {title: '账单', icon: 'order'}, menu: 'sale'
      },
      {
        path: 'payment',
        name: '支付信息',
        component: _import('payment/payment'),
        meta: {title: '支付信息', icon: 'payment'},
        menu: 'payment'
      }
    ]
  },
  {
    path: '/dishes',
    component: Layout,
    redirect: '/dishes/',
    name: 'dishes',
    meta: {title: '菜品', icon: 'dishes'},
    children: [
      {
        path: '', name: '菜品', component: _import('dishes/dishes'), meta: {title: '菜品', icon: 'food'}, menu: 'dishes'
      },
      {
        path: 'type',
        name: '菜品分类',
        component: _import('dishestype/dishestype'),
        meta: {title: '菜品分类', icon: 'type'},
        menu: 'dishesType'
      }
    ]
  },
  
  
  {
    path: '/user',
    component: Layout,
    redirect: '/user/',
    name: 'user',
    meta: {title: '用户管理', icon: 'user'},
    children: [
      {
        path: '', name: '用户', component: _import('user/user'), meta: {title: '用户', icon: 'user'}, menu: 'user'
      },
      {
        path: 'role',
        name: '角色',
        component: _import('user/role'),
        meta: {title: '角色', icon: 'role'},
        menu: 'role'
      },
      {
        path: 'menu',
        name: '系统菜单',
        component: _import('user/sysmenu'),
        meta: {title: '系统菜单', icon: 'menu'},
        menu: 'menu'
      }
    ]
  },
  {
    path: '/charts',
    component: Layout,
    redirect: '/charts/',
    name: 'charts',
    meta: {title: '报表', icon: 'chart'},
    children: [
      {
        path: '', name: '报表', component: _import('charts/charts'), meta: {title: '报表', icon: 'chart'}, menu: 'dishes'
      }
    ]
  },
  {path: '*', redirect: '/404', hidden: true}
]
